package com.wiloon.java8x;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * Created by USER on 2015/8/14.
 */
public class PropertiesHelper {
    private static Properties properties;

    public static void loadProperties() {
        try {
            String configPath = System.getenv("javaeex_config");
            String configFile = configPath + File.separator + "javaeex.properties";
            //InputStream inputStream = Object.class.getResourceAsStream(configFile);
            FileInputStream inputStream = new FileInputStream(configFile);
            properties = new Properties();

            properties.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static String getProperty(String key) {
        if (properties == null) {
            loadProperties();
        }
        return properties.getProperty(key);
    }
}
